﻿@using Microsoft.AspNet.Identity

@Styles.Render("~/Content/cssNavBar")
@Styles.Render("~/Content/css")
@Scripts.Render("~/Scripts/sweetalert.min.js")
@{

    if (HttpContext.Current.User.Identity.IsAuthenticated)
    {
        if (Session["UserInfo"] != null)
        {
            DHQGHN.PM2.Security.MyPrincipalSerializeModel Info = Session["UserInfo"] as DHQGHN.PM2.Security.MyPrincipalSerializeModel;
            <script>
                function toUTF8(strIn) {
                    var strRet;
                    var objRegExp = new RegExp("(&#[\\d]+;)", "gi");
                    strRet = strIn.replace(objRegExp,
                        function (strMatch) {
                            intCode = strMatch.substring(2, strMatch.length - 1);
                            return String.fromCharCode(intCode);
                        }
                    );
                    return strRet;
                }
                $(document).ready(function () {
                    $('#menu1').click(function () {
                        var UserName = '@Info.UserName',
                        FullName = '@Info.FullName',
                        AdminName = '@Info.AdminName',
                            GroupName = '@Info.GroupName';

                        //return alert('\u202User Name : ' + UserName + '\nFull Name: ' + FullName + '\nAdmin Name: ' + AdminName);
                        //swal("Hello " + UserName + "", "Full Name: " + FullName + "\nAdmin Name: " + AdminName + "", "success");
                        swal({
                            title: toUTF8(FullName),
                            text: "Tên đăng nhập : " + toUTF8(UserName) +
                                "\nĐơn vị hành chính : " + toUTF8(AdminName) +
                                "\nNhóm : " + toUTF8(GroupName),
                            imageUrl: "../Images/Logo_TCTK.jpg"
                        });
                    });
                    $("#LogOff").click(function () {
                        swal(
                            {
                                title: "Bạn có muốn đăng xuất khỏi hệ thống ?",
                                //text: "Bạn có muốn đăng xuất khỏi hệ thống ?",
                                type: "warning",
                                cancelButtonText: "Ở Lại",
                                showCancelButton: true,
                                confirmButtonColor: "#DD6B55",
                                confirmButtonText: "Đăng Xuất",
                                closeOnConfirm: false
                            },
                            function () {
                                swal({
                                    title: "Cám ơn bạn đã dùng hệ thống",
                                    text: "Thông báo sẽ tắt trong 2 giây",
                                    imageUrl: "../Images/Logo_TCTK.jpg",
                                    timer: 2000,
                                    showConfirmButton: false,

                                },
                                function () { document.getElementById('logoutForm').submit(); });

                            });
                    });
                });

            </script>
            using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" }))
            {
                @Html.AntiForgeryToken()
                <div id="centeredmenu" class="navbar-collapse collapse">
                    @* Quang_29/06/2015: thay Hello thanh Xin chao *@
                    @Html.Partial("_PartialMenu")
                    @*</div>
                        <div id="nav_user" class="nav navbar-nav">*@
                    <ul id="nav_user" class="nav navbar-nav ">
                        <li class="dropdown">

                            @*@Html.ActionLink("Xin chào " + User.Identity.GetUserName() + "!", null, null, routeValues: null, htmlAttributes: new { @id = "menu1", Href = "#" }) @*"setCookie('frontEnd',1,7);" })*@
                            @Html.ActionLink(Info.FullName @*User.Identity.GetUserName()*@ + " - " + Info.GroupName, null, null, routeValues: null, htmlAttributes: new { @id = "menu1", Href = "#" }) @*"setCookie('frontEnd',1,7);" })*@
                            @*<a id="menu1" href="#" onclick="return alert('User Name : ' + UserName + '\nFull Name: ' + FullName +'\nAdmin Name: ' + AdminName);">Xin chào @User.Identity.GetUserName()</a>*@
                            @*<a id="menu1" href="#"> xin chào @User.Identity.GetUserName()</a>*@

                        </li>
                        @*<li class="dropdown"><a href="javascript:document.getElementById('logoutForm').submit()">Đăng xuất</a></li>*@
                        <li class="dropdown">
                            @*@Html.ActionLink("Đăng xuất", null, null, routeValues: null, htmlAttributes: new { @id = "LogOff" })*@
                            <a id="LogOff">Đăng xuất</a>
                        </li>
                    </ul>
                </div>
            }
        }
    }
    else
    {
        //phunx1, 20150615: phan nay phai viet them mot trang thong bao nguoi dung chua dang nhap. Trang hien thi login de chuyen sang dang nhap
        @*<ul class="nav navbar-nav navbar-right">
                <li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
                <li>@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })</li>
            </ul>*@
    }
}


